#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > cc_energy_triplet3.info <<'%EOF%'
   cc_energy_triplet
   -----------------
   Molecule:         H2O
   Wave Function:    CCS, CC2, CCSD, CC3 / 6-31G
   Test Purpose:     Triplet excitation energies
%EOF%

#######################################################################
#  INTEGRAL INPUT
#######################################################################
cat > cc_energy_triplet3.mol <<'%EOF%'
BASIS
6-31G
H2O in 6-31G basis set
Triplet excitation tests
    3               1.00D-18
        8.    1
O     0.0        -0.12585272  0.0
        1.    1
H1   -1.42717891  0.99868674  0.0
        1.    1
H2    1.42717891  0.99868674  0.0
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > cc_energy_triplet3.dal <<'%EOF%'
**DALTON INPUT
.RUN WAVE FUNCTIONS
**WAVE FUNCTIONS
.TITLE
Triplet excitation energies, CH2 test
.CC
*SCF INPUT
#.DOUBLY OCCUPIED
# 3 1 0 0
.THRESHOLD
 1.0D-9
*CC INPUT
.CCS
.CC2
.CCSD
.CC3
#.RESTART
.MAX ITE
  300
#.MXLRV
#  30
#.MXDIIS
#  30
.MAXRED
  300
#.THRLEQ
#1.0D-8
.THRENR
1.0D-9
.PRINT
   2
.NSYM
  4
*CCEXCI
.NCCEXCI
 0 0 0 0
 2 1 2 1
.THREXC
1.0D-8
.TOLSC
1.0D-5
**END OF DALTON INPUT
%EOF%
#######################################################################

 

#######################################################################
#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >cc_energy_triplet3.check
cat >>cc_energy_triplet3.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

# SCF, MP2 and CCSD energies:
CRIT1=`$GREP "Final * HF energy:" $log | $GREP "\-75.98351120" | wc -l`
CRIT2=`$GREP "Total MP2  * energy: * \-76.11276975" $log | wc -l`
CRIT3=`$GREP "Total CC2  * energy: * \-76.11356592" $log | wc -l`
CRIT4=`$GREP "Total CCSD * energy: * \-76.11931320" $log | wc -l`
CRIT5=`$GREP "Total CC3  * energy: * \-76.12036057" $log | wc -l`
TEST[1]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5`
CTRL[1]=9
ERROR[1]="ENERGIES NOT CORRECT"


# CCS excitation energies:
CRIT1=`$GREP "\^3A1  \|    1   \|     ( |0)\.376794.  \|      10\.253..  \|     82696\....  \| 100\.00" $log | wc -l`
CRIT2=`$GREP "\^3A1  \|    2   \|     ( |0)\.566111.  \|      15\.4046.  \|    124247\....  \| 100\.00" $log | wc -l`
CRIT3=`$GREP "\^3B1  \|    1   \|     ( |0)\.309350.  \|       8\.4178.  \|     67894\....  \| 100\.00" $log | wc -l`
CRIT4=`$GREP "\^3B2  \|    1   \|     ( |0)\.440899.  \|      11\.9974.  \|     96766\....  \| 100\.00" $log | wc -l`
CRIT5=`$GREP "\^3B2  \|    2   \|     ( |0)\.506101.  \|      13\.7717.  \|    111076\....  \| 100\.00" $log | wc -l`
CRIT6=`$GREP "\^3A2  \|    1   \|     ( |0)\.39147..  \|      10\.6525.  \|     85918\....  \| 100\.00" $log | wc -l`
TEST[2]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6`
CTRL[2]=6
ERROR[2]="CCS EXCITATION ENERGIES NOT CORRECT"


# CC2 excitation energies:
CRIT1=`$GREP "\^3A1  \|    1   \|     ( |0)\.360244.  \|       9\.8027.  \|     79064\....  \| " $log | wc -l`
CRIT2=`$GREP "\^3A1  \|    2   \|     ( |0)\.578866.  \|      15\.7517.  \|    127046\....  \| " $log | wc -l`
CRIT3=`$GREP "\^3B1  \|    1   \|     ( |0)\.277850.  \|       7\.5607.  \|     60981\....  \| " $log | wc -l`
CRIT4=`$GREP "\^3B2  \|    1   \|     ( |0)\.43993..  \|      11\.9712.  \|     96554\....  \| " $log | wc -l`
CRIT5=`$GREP "\^3B2  \|    2   \|     ( |0)\.508109.  \|      13\.8263.  \|    111517\....  \| " $log | wc -l`
CRIT6=`$GREP "\^3A2  \|    1   \|     ( |0)\.37161..  \|      10\.1121.  \|     81559\....  \| " $log | wc -l`
TEST[3]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6`
CTRL[3]=6
ERROR[3]="CC2 EXCITATION ENERGIES NOT CORRECT"


# CCSD excitation energies:
CRIT1=`$GREP "\^3A1  \|    1   \|     ( |0)\.362893.  \|       9\.8748.  \|     79645\....  \| " $log | wc -l`
CRIT2=`$GREP "\^3A1  \|    2   \|     ( |0)\.579153.  \|      15\.7595.  \|    127109\....  \| " $log | wc -l`
CRIT3=`$GREP "\^3B1  \|    1   \|     ( |0)\.279655.  \|       7\.6098.  \|     61377\....  \| " $log | wc -l`
CRIT4=`$GREP "\^3B2  \|    1   \|     ( |0)\.442149.  \|      12\.0315.  \|     97040\....  \| " $log | wc -l`
CRIT5=`$GREP "\^3B2  \|    2   \|     ( |0)\.510426.  \|      13\.8894.  \|    112025\....  \| " $log | wc -l`
CRIT6=`$GREP "\^3A2  \|    1   \|     ( |0)\.37194..  \|      10\.1210.  \|     81632\....  \| " $log | wc -l`
TEST[4]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6`
CTRL[4]=6
ERROR[4]="CCSD EXCITATION ENERGIES NOT CORRECT"


# CC3 excitation energies:
CRIT1=`$GREP "\^3A1  \|    1   \|     ( |0)\.365912.  \|       9\.9569.  \|     80308\....  \| " $log | wc -l`
CRIT2=`$GREP "\^3A1  \|    2   \|     ( |0)\.579607.  \|      15\.7719.  \|    127209\....  \| " $log | wc -l`
CRIT3=`$GREP "\^3B1  \|    1   \|     ( |0)\.28310..  \|       7\.7037.  \|     62134\....  \| " $log | wc -l`
CRIT4=`$GREP "\^3B2  \|    1   \|     ( |0)\.444004.  \|      12\.0819.  \|     97447\....  \| " $log | wc -l`
CRIT5=`$GREP "\^3B2  \|    2   \|     ( |0)\.511006.  \|      13\.9052.  \|    112153\....  \| " $log | wc -l`
CRIT6=`$GREP "\^3A2  \|    1   \|     ( |0)\.373730.  \|      10\.1697.  \|     82024\....  \| " $log | wc -l`
TEST[5]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6`
CTRL[5]=6
ERROR[5]="CC3 EXCITATION ENERGIES NOT CORRECT"


PASSED=1
for i in 1 2 3 4 5
do
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM
  exit 1
fi                
%EOF%
#######################################################################
